package com.huaxin.device.dto.enums.validator;

import com.huaxin.device.dto.enums.ConnectionType;
import com.huaxin.device.dto.enums.validation.ValidConnectionType;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class ConnectionTypeValidator implements ConstraintValidator<ValidConnectionType, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null || value.trim().isEmpty()) {
            return true; // 可空字段通过
        }
        return ConnectionType.isValid(value);
    }
}